import Vue from 'vue'
import VueRouter from 'vue-router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

const index = () =>
    import ('../views/index.vue')
const information = () =>
    import ('../views/information.vue')
const login = () =>
    import ('../views/login.vue')

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(ElementUI)
Vue.use(VueRouter)

const router = new VueRouter({
    routes: [{
        path: '',
        redirect: '/login'

    }, {
        path: '/index',
        component: index,
        meta: {
            title: 'index'
        },
    }, {
        path: '/information',
        component: information,
        meta: {
            title: 'information'
        },
    }, {
        path: '/login',
        component: login,
        meta: {
            title: 'login'
        },
    }],
    linkActiveClass: 'active',
    mode: 'history'
})


router.beforeEach((to, from, next) => {
    window.document.title = to.meta.title;
    next();
})

export default router